//
//  EnergyVC.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/14.
//

#import "EnergyVC.h"
#import "EnergyHeaderView.h"
#import "EnergyShopListCell.h"
@interface EnergyVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView * listView;
@property (nonatomic,strong) EnergyHeaderView * headView;
@end

@implementation EnergyVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setSubViewLayout];
}

-(void)setSubViewLayout{
      
    [self.view addSubview:self.listView];
    [self.view bringSubviewToFront:self.navgationView];
    
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"StartAnimation" object:@"" userInfo:nil];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"RefshCoin" object:@"" userInfo:nil];

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 300 * FMScaleX;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    EnergyShopListCell * cell = [tableView dequeueReusableCellWithIdentifier:@"EnergyShopListCell"];
    return cell;
}


-(EnergyHeaderView *)headView{
    
    if (!_headView) {
        _headView = [[EnergyHeaderView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 450 * FMScaleX)];
    }
    return _headView;
}

-(UITableView *)listView{
    
    if (!_listView) {
        _listView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, WIDTH, HEIGHT  - kSafeAreaHeight  - TabBarHeight)];
        _listView.delegate = self;
        _listView.dataSource = self;
        _listView.showsVerticalScrollIndicator = NO;
        _listView.showsHorizontalScrollIndicator = NO;
        _listView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _listView.backgroundColor = UIColor.clearColor;
        [_listView registerClass:[EnergyShopListCell class] forCellReuseIdentifier:@"EnergyShopListCell"];
        _listView.tableHeaderView = self.headView;
    }
    return _listView;
}
@end
